// pages/designerList/designerDetail.js
//获取应用实例
const api = require("../../utils/app1.js")
const app = getApp()
import Notify from '../../miniprogram_npm/@vant/weapp/notify/notify';
Page({
 
  /**
   * 页面的初始数据
   */
  data: {
    designerDetail: {},
    price:0,
    dialogHidden:true,
    btnStatus:true,
    id:"",name:"",isCk:"",brand:"",xinghao:"",count:"",sn:"",source:"",rukuData:"",makeS:""
  },
 
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;

    wx.showNavigationBarLoading();
  },
  
  //图片预览
  bindpreviewImage: function (e){
    var that = this;
    console.log(e.currentTarget.id)
    var index = e.currentTarget.id;
    var picslist = that.data.designerDetail.pics;
    for (var i in picslist) {
      picslist[i] = that.data.urlhttp + picslist[i];
    }
    wx.previewImage({
      current: picslist[index], // 当前显示图片的http链接
      urls: picslist // 需要预览的图片http链接列表
    })
  },
  orderTap: function (e) {
    var that = this;
    console.log(e)
    that.setData({
      orderType: e.target.dataset.type,
      dialogHidden: false,
    })
  },
  closeTap: function () {
    var that = this;
    that.setData({
      dialogHidden: true,
    })
  },
  formSubmit: function (e) {
    var that = this;
    var value = e.detail.value;
    console.log(value)

/*     //姓名
    if (value.name == "" || value.name == null) {
      wx.showModal({
        title: "",
        content: '姓名不能为空，请输入姓名',
        showCancel: false,
        success: function (res) {
          if (res.confirm) {
            console.log('用户点击确定')
          }
        }
      })
      that.setData({
        btnStatus: true,
      })
      return false;
    } */
    let {
      id,name,isCk,brand,xinghao,count,sn,source,rukuData,makeS
    } = value
    that.setData({
      id,name,isCk,brand,xinghao,count,sn,source,rukuData,makeS
    })
    let data = { id,name,isCk,brand,xinghao,count,sn,source,rukuData,makeS}
    api.postInfo("/ck/cklist/save",data).then(res => {
      console.log(res)
      Notify({
        type: 'success',
        message: '提交成功'
    });

    wx.showNavigationBarLoading();  
    that.setData({
      dialogHidden: true,
    })
  })

},

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
 
  },
 
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
 
  },
 
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
 
  },
 
  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
 
  },
 
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
 
  },
 
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
 
  },
 
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
 
  }
})